{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-11-14T09:04:15.288186Z",
     "start_time": "2025-11-14T09:04:15.276901Z"
    }
   },
   "source": [
    "from datetime import datetime\n",
    "\n",
    "import pandas as pd\n",
    "data_index=pd.to_datetime(['2012','2013','2014'])\n",
    "data_ser=pd.Series(['12','13','14'],index=data_index)\n",
    "print(data_ser)"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2012-01-01    12\n",
      "2013-01-01    13\n",
      "2014-01-01    14\n",
      "dtype: object\n"
     ]
    }
   ],
   "execution_count": 6
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-14T09:08:25.852841Z",
     "start_time": "2025-11-14T09:08:25.844261Z"
    }
   },
   "cell_type": "code",
   "source": [
    "data=[[1,2,3],[4,5,6],[7,8,9]]\n",
    "data1=pd.Series([1,2,3],index=data)\n",
    "print(data1)"
   ],
   "id": "bc557cd20ea8ddb8",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1  4  7    1\n",
      "2  5  8    2\n",
      "3  6  9    3\n",
      "dtype: int64\n"
     ]
    }
   ],
   "execution_count": 12
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-14T09:24:29.984362Z",
     "start_time": "2025-11-14T09:24:29.978002Z"
    }
   },
   "cell_type": "code",
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "date_list = ['2020', '2022', '2020', '2021', '2022', '2023']\n",
    "date_index = pd.to_datetime(date_list)\n",
    "date_ser = pd.Series(np.arange(6), index=date_index)\n",
    "print(date_ser)"
   ],
   "id": "8714d427274c0bff",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2020-01-01    0\n",
      "2022-01-01    1\n",
      "2020-01-01    2\n",
      "2021-01-01    3\n",
      "2022-01-01    4\n",
      "2023-01-01    5\n",
      "dtype: int64\n"
     ]
    }
   ],
   "execution_count": 21
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-14T09:37:14.937087Z",
     "start_time": "2025-11-14T09:37:14.931406Z"
    }
   },
   "cell_type": "code",
   "source": [
    "\n",
    "dates_index = pd.date_range(\n",
    "    start='2023-01-01 12:30:11',\n",
    "    periods=5,\n",
    "    freq='5D'\n",
    ")\n",
    "print(dates_index)\n",
    "print(\"\\n时间序列数据类型：\", dates_index.dtype)\n",
    "print(\"时间间隔（freq）：\", dates_index.freq)"
   ],
   "id": "ece0c395f250b38d",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DatetimeIndex(['2023-01-01 12:30:11', '2023-01-06 12:30:11',\n",
      "               '2023-01-11 12:30:11', '2023-01-16 12:30:11',\n",
      "               '2023-01-21 12:30:11'],\n",
      "              dtype='datetime64[ns]', freq='5D')\n",
      "\n",
      "时间序列数据类型： datetime64[ns]\n",
      "时间间隔（freq）： <5 * Days>\n"
     ]
    }
   ],
   "execution_count": 23
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
